package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaAppMapper;
import com.ruoyi.work.domain.WorkMediaApp;
import com.ruoyi.work.service.IWorkMediaAppService;
import com.ruoyi.common.core.text.Convert;

/**
 * APP客户端媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaAppServiceImpl implements IWorkMediaAppService
{
    @Autowired
    private WorkMediaAppMapper workMediaAppMapper;
    @Autowired
    private WorkClientMapper workClientMapper;

    /**
     * 查询APP客户端媒体资料
     * 
     * @param mediaId APP客户端媒体资料主键
     * @return APP客户端媒体资料
     */
    @Override
    public WorkMediaApp selectWorkMediaAppByMediaId(Long mediaId)
    {
        return workMediaAppMapper.selectWorkMediaAppByMediaId(mediaId);
    }

    /**
     * 查询APP客户端媒体资料列表
     * 
     * @param workMediaApp APP客户端媒体资料
     * @return APP客户端媒体资料
     */
    @Override
    public List<WorkMediaApp> selectWorkMediaAppList(WorkMediaApp workMediaApp)
    {
        return workMediaAppMapper.selectWorkMediaAppList(workMediaApp);
    }

    /**
     * 新增APP客户端媒体资料
     * 
     * @param workMediaApp APP客户端媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaApp(WorkMediaApp workMediaApp)
    {
        workMediaApp.setCreateTime(DateUtils.getNowDate());
        workMediaApp.setContacts(workClientMapper.selectWorkClientByClientId(workMediaApp.getContactId()).getClientName());
        return workMediaAppMapper.insertWorkMediaApp(workMediaApp);
    }

    /**
     * 修改APP客户端媒体资料
     * 
     * @param workMediaApp APP客户端媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaApp(WorkMediaApp workMediaApp)
    {
        workMediaApp.setUpdateTime(DateUtils.getNowDate());
        return workMediaAppMapper.updateWorkMediaApp(workMediaApp);
    }

    /**
     * 批量删除APP客户端媒体资料
     * 
     * @param mediaIds 需要删除的APP客户端媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaAppByMediaIds(String mediaIds)
    {
        return workMediaAppMapper.deleteWorkMediaAppByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除APP客户端媒体资料信息
     * 
     * @param mediaId APP客户端媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaAppByMediaId(Long mediaId)
    {
        return workMediaAppMapper.deleteWorkMediaAppByMediaId(mediaId);
    }


}
